﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLBH.DAO;
using QLBH.DTO;
using System.Data;

namespace QLBH.BLO
{
    class BLO_TTTToan
    {
        DAO_TTTToan dao_ttttoan = new DAO_TTTToan();
        public int Insert(TTTT t)
        {
            try
            {
                DataTable idmax = Connection_Sql.GetDatatable("select max(ma_TTTT) from Thongtinthanhtoan", false);
                int map = 1;
                if (idmax.Rows[0][0].ToString() == "")
                {
                    t.Ma_tttt = map.ToString();
                }
                else
                {
                   t.Ma_tttt = (int.Parse(idmax.Rows[0][0].ToString()) + 1).ToString();
                }
                return dao_ttttoan.Insert(t);
            }
            catch (System.Exception ex)
            {
                throw new Exception("Lỗi BLO Insert Thong tin thanh toan: " + ex.Message);
            }
        }
    }
}
